import request from '@/utils/request';

import { MATERIAL } from './utils';

/**
 * 获取用户信息
 */
export function fetchEmployeeInfo(candidateCode) {
    return request(`/api/entry/candidate/process/v2/queryCandidateProcessDetail/${candidateCode}`, {
        method: 'GET'
    });
}

/**
 * 获取用户档案信息
 */
export function fetchEmployeeArchivesData(candidateCode) {
    return request('/api/entry/v1/employee/getAllDoc', {
        method: 'POST',
        data: { entryPersonnelCode: candidateCode }
    });
}

/**
 * 获取用户基础信息
 */
export function saveEmployeeBasicInfo(param) {
    return request('/api/entry/v1/employee/updateBasic', {
        data: param,
        method: 'POST'
    });
}

/**
 * 修改紧急联系人
 */
export function saveEmployeeEmergencyData(param) {
    return request('/api/entry/v1/employee/updateEmergency', {
        data: param,
        method: 'POST'
    });
}

/**
 * 修改工作经历
 */
export function saveEmployeeWorkData(param) {
    return request('/api/entry/v1/employee/updateWork', {
        data: param,
        method: 'POST'
    });
}

/**
 * 修改教育经历
 */
export function saveEmployeeEducationalData(param) {
    return request('/api/entry/v1/employee/updateEdu', {
        data: param,
        method: 'POST'
    });
}

/**
 * 修改家庭成员
 */
export function saveEmployeeFamilyData(param) {
    return request('/api/entry/v1/employee/updateFamily', {
        data: param,
        method: 'POST'
    });
}

/**
 * 修改培训经历
 */
export function saveEmployeeTrainingData(param) {
    return request('/api/entry/v1/employee/updateTrain', {
        data: param,
        method: 'POST'
    });
}

/**
 * 修改获奖记录
 */
export function saveEmployeeAwardData(param) {
    return request('/api/entry/v1/employee/updateAward', {
        data: param,
        method: 'POST'
    });
}

/**
 * 更新语言信息
 */
export function saveLanguages(params) {
    return request('/api/entry/v1/employee/updateLang', {
        method: 'POST',
        data: params
    });
}

/**
 * 更新技能信息
 */
export function saveSkill(params) {
    return request('/api/entry/v1/employee/updateSkill', {
        method: 'POST',
        data: params
    });
}

/**
 * 删除工作经历
 */
export function deleteEmployeeWorkDataById({ entryPersonnelCode, id }) {
    return request('/api/entry/v1/employee/forH5/deleteWork', {
        method: 'POST',
        data: { entryPersonnelCode, id }
    });
}

/**
 * 删除教育经历
 */
export function deleteEmployeeEducationalDataById({ entryPersonnelCode, id }) {
    return request('/api/entry/v1/employee/forH5/deleteEdu', {
        method: 'POST',
        data: { entryPersonnelCode, id }
    });
}

/**
 * 删除家庭成员
 */
export function deleteEmployeeFamilyDataById({ entryPersonnelCode, id }) {
    return request('/api/entry/v1/employee/forH5/deleteFamily', {
        method: 'POST',
        data: { entryPersonnelCode, id }
    });
}

/**
 * 删除培训经历
 */
export function deleteEmployeeTrainingDataById({ entryPersonnelCode, id }) {
    return request('/api/entry/v1/employee/forH5/deleteTrain', {
        method: 'POST',
        data: { entryPersonnelCode, id }
    });
}

/**
 * 删除获奖记录
 */
export function deleteEmployeeAwardDataById({ entryPersonnelCode, id }) {
    return request('/api/entry/v1/employee/forH5/deleteAward', {
        method: 'POST',
        data: { entryPersonnelCode, id }
    });
}

/**
 * 删除语言信息
 */
export function deleteLanguagesById({ entryPersonnelCode, id }) {
    return request('/api/entry/v1/employee/forH5/deleteLang', {
        method: 'POST',
        data: { entryPersonnelCode, id }
    });
}

/**
 * 删除技能信息
 */
export function deleteSkillById({ entryPersonnelCode, id }) {
    return request('/api/entry/v1/employee/forH5/deleteSkill', {
        method: 'POST',
        data: { entryPersonnelCode, id }
    });
}

/**
 * 保存单个工作经历
 */
export function saveEmployeeWorkSingle(param) {
    return request('/api/entry/v1/employee/forH5/updateWork4H5', {
        data: param,
        method: 'POST'
    });
}

/**
 * 保存单个教育经历
 */
export function saveEmployeeEducationalSingle(param) {
    return request('/api/entry/v1/employee/forH5/updateEdu4H5', {
        data: param,
        method: 'POST'
    });
}

/**
 * 保存单个家庭成员
 */
export function saveEmployeeFamilySingle(param) {
    return request('/api/entry/v1/employee/forH5/updateFamily4H5', {
        data: param,
        method: 'POST'
    });
}

/**
 * 保存单个培训经历
 */
export function saveEmployeeTrainingSingle(param) {
    return request('/api/entry/v1/employee/forH5/updateTrain4H5', {
        data: param,
        method: 'POST'
    });
}

/**
 * 保存单个获奖记录
 */
export function saveEmployeeAwardSingle(param) {
    return request('/api/entry/v1/employee/forH5/updateAward4H5', {
        data: param,
        method: 'POST'
    });
}

/**
 * 保存单个语言信息
 */
export function saveLanguSingle(params) {
    return request('/api/entry/v1/employee/forH5/updateLang4H5', {
        method: 'POST',
        data: params
    });
}

/**
 * 保存单个技能信息
 */
export function saveSkillsSingle(params) {
    return request('/api/entry/v1/employee/forH5/updateSkill4H5', {
        method: 'POST',
        data: params
    });
}

/**
 * 保存单个获奖记录
 */
export function getAwardById(id) {
    return request(`/api/entry/v1/employee/forH5/getAward4H5/${id}`, {
        method: 'GET'
    });
}

/**
 * 保存单个教育经历
 */
export function getEduById(id) {
    return request(`/api/entry/v1/employee/forH5/getEduById/${id}`, {
        method: 'GET'
    });
}

/**
 * 保存单个家庭成员
 */
export function getFamilyById(id) {
    return request(`/api/entry/v1/employee/forH5/getFamilyById/${id}`, {
        method: 'GET'
    });
}

/**
 * 保存单个语言
 */
export function getLangById(id) {
    return request(`/api/entry/v1/employee/forH5/getLangById/${id}`, {
        method: 'GET'
    });
}

/**
 * 保存单个专业技能
 */
export function getSkillById(id) {
    return request(`/api/entry/v1/employee/forH5/getSkillById/${id}`, {
        method: 'GET'
    });
}

/**
 * 保存单个培训经历
 */
export function getWorkById(id) {
    return request(`/api/entry/v1/employee/forH5/getWorkById/${id}`, {
        method: 'GET'
    });
}

/**
 * 保存单个工作经历
 */
export function getTrainById(id) {
    return request(`/api/entry/v1/employee/forH5/getTrainById/${id}`, {
        method: 'GET'
    });
}

/**
 * 修改获奖记录
 */
export function fetchEntryRecordList(candidateCode) {
    return request(`/api/entry/v1/process/record/queryEntryRecordList/${candidateCode}`, {
        method: 'POST'
    });
}

/**
 * 获取入职人员信息
 */
export function fetchEntryPersonnelInfo(params) {
    return request('/api/entry/employee/v2/queryEntryPersonalBasicInfo', {
        method: 'POST',
        data: params
    });
}

/**
 * 办理入职 - 签署劳动合同
 */
export function fetchLaborContract(param) {
    return request('/api/entry/v1/process/dealEntryByHR', {
        data: param,
        method: 'POST'
    });
}

export function fetchDealEntryByHR(param) {
    return request('/api/entry/candidate/process/v2/dealEntryByHR', {
        data: param,
        method: 'POST'
    });
}

/**
 * 办理入职 - 上传材料文件
 */
export function fetchUploadMaterialsFile(param, materialsType) {
    let fetchUrl;
    switch (materialsType) {
        // 入职人员学位证书
        case MATERIAL.EDUCATION:
            fetchUrl = '/api/entry/v1/onboard/uploadEducationCertificate';
            break;
        // 入职人员身份证
        case MATERIAL.ID_CARD:
            fetchUrl = '/api/entry/v1/onboard/uploadIdCard';
            break;
        // 入职人员体检报告
        case MATERIAL.MEDICAL_REPORT:
            fetchUrl = '/api/entry/v1/onboard/uploadMedicalReport';
            break;
        // 入职人员相关资格证书
        case MATERIAL.RELATED_QUALIFICATIONS:
            fetchUrl = '/api/entry/v1/onboard/uploadRelatedQualifications';
            break;
        // 入职人员离职证明
        case MATERIAL.RESIGNATION:
            fetchUrl = '/api/entry/v1/onboard/uploadResignationCertificate';
            break;
        // 入职人员已签订劳动合同扫描件
        case MATERIAL.SIGNED_CONTRACT:
            fetchUrl = '/api/entry/v1/onboard/uploadSignedContract';
            break;
        // 入职人员本科证书
        case MATERIAL.UNDERGRADUATE:
            fetchUrl = '/api/entry/v1/onboard/uploadUndergraduateCertificate';
            break;
        case MATERIAL.ID_PHOTO:
            fetchUrl = '/api/entry/v1/onboard/uploadIdPhoto';
            break;
        case MATERIAL.XUE_XIN_NET:
            fetchUrl = '/api/entry/v1/onboard/uploadXueXin';
            break;
        case MATERIAL.OTHER_CONTRACT:
            fetchUrl = '/api/entry/v1/onboard/uploadOtherContract';
            break;
        default:
            fetchUrl = '';
            break;
    }
    if (!fetchUrl) {
        return Promise.reject(new Error('请求失败'));
    }
    return request(fetchUrl, {
        data: param,
        method: 'POST'
    });
}

/**
 * 待入职列表
 */
export function queryCandidateProcessList(param) {
    return request('/api/entry/candidate/process/v2/queryCandidateProcessList', {
        data: param,
        method: 'POST'
    });
}

/**
 * 历史记录列表
 */
export function queryCandidateProcessHistoryList(param) {
    return request('/api/entry/candidate/process/v2/queryCandidateProcessHistoryList', {
        data: param,
        method: 'POST'
    });
}

/**
 * 获取办公用具
 */
export function fetchOfficeAssetInst(entryPersonnelCode) {
    return request(`/api/entry/v1/onboard/queryOfficeAssetInst/${entryPersonnelCode}`, {
        method: 'GET'
    });
}

/**
 * 获取预装软件列表
 */
export function getSoft(param) {
    return request('/api/entry/v1/soft/queryList', {
        method: 'POST',
        data: param
    });
}

/**
 * 员工指引-信息确认
 */
export function insertDevice(param) {
    return request('/api/entry/v1/soft/v1/employee/insertDevice', {
        method: 'POST',
        data: param
    });
}

/**
 * 员工指引-提交材料
 */
export function saveMaterials(param) {
    return request('/api/entry/employee/v2/materials', {
        method: 'POST',
        data: param
    });
}

/**
 * 选择的预装软件
 */
export function preloadedSoft(param) {
    return request('/api/entry/v1/soft/selected', {
        method: 'POST',
        data: param
    });
}

/**
 * 选择的设备
 */
export function getEntryDevice(param) {
    return request('/api/entry/v1/device/query', {
        method: 'POST',
        data: param
    });
}

/**
 * 终止入职
 */
export function terminateEntry(param) {
    return request('/api/entry/v1/process/terminateEntry', {
        method: 'POST',
        data: param
    });
}

/**
 * 更新入职时间
 */
export function updateEntryDate(param) {
    return request('/api/entry/v1/process/updateEntryDate', {
        method: 'POST',
        data: param
    });
}

/**
 * 候选人申请更新入职时间
 */
export function applyUpdateEntryDate(param) {
    return request('/api/entry/candidate/process/v2/applyUpdateEntryDate', {
        method: 'POST',
        data: param
    });
}

/**
 * 指派处理人
 */
export function assignHandler(param) {
    return request('/api/entry/candidate/process/v2/assignHandler', {
        method: 'POST',
        data: param
    });
}

/**
 * 查询待入职单条记录记录
 */
export function queryCandidateProcess(code) {
    return request(`/api/entry/candidate/process/v2/queryCandidateProcess/${code}`, {
        method: 'GET'
    });
}

/**
 * 读取入职信息
 */
export function queryCandidateProcessDetail(code) {
    return request(`/api/entry/candidate/process/v2/queryCandidateProcessDetail/${code}`, {
        method: 'GET'
    });
}

/**
 *
 * 删除材料
 */
export function fetchRemoveMaterial(param) {
    return request('/api/entry/v1/onboard/removeEntryResourse', {
        method: 'POST',
        data: param
    });
}

/**
 *
 * 获取工位及工作安排
 */
export function fetchDepartmentEmployeeInfo(param) {
    return request(`/api/entry/v1/onboard/queryDepartmentEmployeeInfo/${param}`, {
        method: 'GET'
    });
}

/**
 * 获取入职人员简易信息
 */
export function getFirstSimpleInfo(param) {
    return request('/api/entry/v1/employee/getFirstSimpleInfo', {
        method: 'POST',
        data: param
    });
}

/**
 *
 * 获取入职人员简易信息
 */
export function getAreaByCondition(param) {
    return request('/api/dict/area/v1/getAreaByCondition', {
        method: 'POST',
        data: param
    });
}

/** 入职欢迎信
 */
export function queryWelcomeLetter(param) {
    return request('/api/entry/v1/onboard/queryWelcomeLetter', {
        method: 'POST',
        data: param
    });
}

/**
 * 保存社保
 */
export function saveSocial(param) {
    return request('/api/entry/v1/onboard/saveSocial', {
        method: 'POST',
        data: param
    });
}

/**
 * 发放办公物品
 */
export function releaseMaterial(param) {
    return request('/api/entry/candidate/process/v2/releaseMaterials', {
        method: 'POST',
        data: param
    });
}

/**
 * 部门接收
 */
export function departmentAcceptEmployee(param) {
    return request('/api/entry/candidate/process/v2/departmentAcceptEmployee', {
        method: 'POST',
        data: param
    });
}

/*
 *  获取候选人资产列表
 */
export function getPropertyList(entryPersonnelCode) {
    return request(`/api/entry/v1/asset/inst/${entryPersonnelCode}`, {
        method: 'GET'
    });
}

/*
 *  入职办理退回上一个节点
 */
export function backPrevious(params) {
    return request('/api/entry/candidate/process/v2/backPrevious', {
        method: 'POST',
        data: params
    });
}

/*
 * 用人部门准备回填数据，主要用于回退节点回显用
 */
export function getArrangedInfoByDepartment(entryPersonnelCode) {
    return request(`/api/entry/v1/process/arrangedInfoByDepartment/${entryPersonnelCode}`, {
        method: 'GET'
    });
}

export function fetchCheckOfficeGoods(params) {
    return request('/api/uc/employee/manage/v1/asset/accept', {
        method: 'POST',
        data: params
    });
}
export function postStatement(params) {
    return request('/api/entry/v1/process/updateCandidateProcess', {
        method: 'POST',
        data: params
    });
}

/**
 * 入职修改密码
 */
export function fetchChangePwdConfirm() {
    return request('/api/entry/v1/employeeFlag/changePwdConfirm', {
        method: 'POST'
    });
}

export function fetchReadWelcomeLetterConfirm() {
    return request('/api/entry/v1/employeeFlag/readWelcomeLetter', {
        method: 'POST'
    });
}

/**
 * 获取员工状态（主要判断是否为新员工）
 */
export function fetchQueryEmployeeFlag() {
    return request('/api/entry/v1/employeeFlag/queryEmployeeFlag', {
        method: 'GET'
    });
}

/**
 * 获取欢迎信
 */
export function fetchQueryWelcomeLetter() {
    return request('/api/entry/config/queryWelcomeLetter', {
        method: 'GET'
    });
}
/**
 * 获取员工资产
 */

export function fetchEmployeeAssets() {
    return request('/api/entry/v2/asset/query', {
        method: 'GET'
    });
}
/*
 *  获取当前员工入职须知
 */
export function getEntryNotes(params) {
    return request('/api/entry/employee/v2/config/notes', {
        method: 'POST',
        data: params
    });
}

/*
 *  获取当前员工入职材料配置
 */
export function getEntryMaterials(params) {
    return request('/api/entry/employee/v2/config/materials', {
        method: 'POST',
        data: params
    });
}

/**
 * 认识办理入职-获取入职员工材料
 */
export function fetchEmployeeEntryMaterials(employeeCode) {
    return request(`/api/entry/candidate/process/v2/queryEmployeeEntryMaterial/${employeeCode}`, {
        method: 'GET'
    });
}

/**
 * 添加附件
 */
export function fetchSaveFileRelation(params) {
    return request('/api/entry/config/v1/employee/saveFileRelation', {
        method: 'POST',
        data: params
    });
}

/**
 * 删除附件
 */
export function removeFileRelationByCategoryCode(params) {
    return request('/api/entry/config/v1/employee/removeFileRelationByCategoryCode', {
        method: 'POST',
        data: params
    });
}

/*
 *  校验ucc用户姓名邮箱
 */
export function checkAccountNameEmail(params) {
    return request('/api/uc/public/org/user/v1/checkaccountnameemail', {
        method: 'POST',
        data: params
    });
}

/*
 *  招聘入职平台发送验证码
 */
export function sendVerificationCode(params) {
    return request('/api/user/public/v1/recruitentryplatform/verification/send', {
        method: 'POST',
        data: params
    });
}

/*
 *  校验验证码
 */
export function checkVerificationCode(params) {
    return request('/api/user/public/v1/verification/check', {
        method: 'POST',
        data: params
    });
}

/*
 *  重置密码
 */
export function resetForgetPassword(params) {
    return request('/api/user/public/v1/account/recruitentryplatform/forget', {
        method: 'POST',
        data: params
    });
}

/*
 *  查询当前环节可指派的处理人
 */
export function queryCanBeAssignEmployee(entryPersonnelCode) {
    return request(`/api/entry/candidate/process/v2/queryCanBeAssignEmployee/${entryPersonnelCode}`, {
        method: 'GET'
    });
}

/*
 *  面包屑机构路径
 */
export function getOrganizationWithFullName(params) {
    return request('/api/org/v1/getOrganizationWithFullName', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取员工所有材料
 */
export function getEmployeeEntityAllMaterial({ employeeCode }) {
    return request(`/api/entry/employee/v2/allMaterial/${employeeCode}`, {
        method: 'GET'
    });
}

/**
 * 上传员工实体材料信息
 */
export function uploadEmployeeEntityMaterial({ employeeCode, materials }) {
    return request('/api/entry/employee/v2/entityMaterial', {
        method: 'POST',
        data: { employeeCode, materials }
    });
}

/**
 * 删除员工实体材料信息
 */
export function removeEmployeeEntityMaterial({ employeeCode, categoryCode, keyName }) {
    return request('/api/entry/employee/v2/delEntityMaterial', {
        method: 'DELETE',
        data: { employeeCode, categoryCode, keyName }
    });
}
